package com.andengine.editor.atlaseditor;

import com.andengine.editor.data.TextureFile;
import com.swingson.exceptions.ErrorMessageException;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;

/**
 * @author sad
 */
public class TextureInAtlas {

    private final TextureFile textureFile;
    private BufferedImage image;
    private int x;
    private int y;
    private boolean collision = false;

    public TextureInAtlas(TextureFile textureFile, int x, int y) {
        try {
            this.textureFile = textureFile;
            this.x = x;
            this.y = y;
            image = ImageIO.read(textureFile);
        } catch (IOException ex) {
            throw new ErrorMessageException("Cannot load texture " + textureFile.getAbsolutePath());
        }
    }

    public boolean isCollision() {
        return collision;
    }

    public void setCollision(boolean collision) {
        this.collision = collision;
    }

    public TextureFile getTextureFile() {
        return textureFile;
    }

    public BufferedImage getImage() {
        return image;
    }

    public int getX() {
        return x;
    }
    public int getX2() {
        return x+getWidth();
    }

    public void setX(int x) {
        this.x = x;
    }
    
    public int getWidth(){
        return image.getWidth();
    }
    
    public int getHeight(){
        return image.getHeight();
    }

    public int getY() {
        return y;
    }
    public int getY2() {
        return y+getHeight();
    }

    public void setY(int y) {
        this.y = y;
    }

}
